cmake_minimum_required(VERSION 3.10 FATAL_ERROR)

project(recipe-05 LANGUAGES CXX)

add_executable(processor-info processor-info.cpp)
target_include_directories(processor-info PRIVATE ${PROJECT_BINARY_DIR})        # 添加config.h的头文件，在build/下
#message(STATUS "PROJECT_BINARY_DIR: ${PROJECT_BINARY_DIR}")

foreach (key IN ITEMS
            NUMBER_OF_LOGICAL_CORES
            NUMBER_OF_PHYSICAL_CORES
            TOTAL_VIRTUAL_MEMORY
            AVAILABLE_VIRTUAL_MEMORY
            TOTAL_PHYSICAL_MEMORY
            AVAILABLE_PHYSICAL_MEMORY
            IS_64BIT
            HAS_FPU
            HAS_MMX
            HAS_MMX_PLUS
            HAS_SSE
            HAS_SSE2
            HAS_SSE_FP
            HAS_SSE_MMX
            HAS_AMD_3DNOW
            HAS_AMD_3DNOW_PLUS
            HAS_IA64
            OS_NAME
            OS_RELEASE
            OS_VERSION
            OS_PLATFORM
        )
cmake_host_system_information(RESULT _${key} QUERY ${key})                  # 系统查询信息存储在variable--_${key}中
endforeach ()

configure_file(config.h.in config.h @ONLY)                                  # 将文件复制到另一个位置并修改其内容。@ONLY 表示 @VAR@ 类型变量替换